package com.aspose.cells;

import java.util.ArrayList;
import java.util.List;

final class zis {
   static void a(zn var0, ziq var1, int var2, int var3, int var4, boolean var5) throws Exception {
      if (var1.a().u() && !var1.a().B().E()) {
         com.aspose.cells.b.a.b.zs var6 = zbsq.a(var0, "a", var1.b());
         int var7 = var6.b() * var1.a().e().G().c() / 300;
         zig var8 = var1.a();
         int var9 = var8.ap().j();
         if (var8.i().c().i() && var8.ap().j() != 4) {
            var8.ap().b(4);
         }

         int var10 = var8.N();
         boolean var11 = var8.e().p();
         com.aspose.cells.b.a.b.zs var12 = var1.k();
         int var13 = var12.c() + var1.l();
         com.aspose.cells.b.a.b.zt var14 = zald.a(var0, var1.a().x());
         ArrayList var15 = var1.j().a(true, var5);
         com.aspose.cells.b.a.b.zp var16 = new com.aspose.cells.b.a.b.zp(var2, var3, var4, var13);
         com.aspose.cells.b.a.b.zp var17 = new com.aspose.cells.b.a.b.zp(var2 - var12.b(), var3 + var1.l(), var4 + var12.b(), var12.c());
         if (var1.i()) {
            var1.d().a(var16);
            var1.d().a(var17);
         }

         float var18 = (float)var12.c() / (float)var15.size();
         float var19;
         float var20;
         int var23;
         if (var1.h()) {
            for(var23 = 1; var23 < var15.size(); ++var23) {
               var19 = (float)var17.g();
               var20 = (float)var17.h() + (float)var23 * var18;
               float var21 = (float)var17.i();
               var1.d().a(var19, var20, var21, var20);
            }
         }

         var23 = var8.z().h();
         com.aspose.cells.b.a.b.zg var24 = var1.b();
         com.aspose.cells.b.a.b.zu var25 = new com.aspose.cells.b.a.b.zu(var1.c());
         float var26 = (float)var4 / (float)var23;
         zbp var27 = var8.e();
         zafs var28 = var8.z().a();
         ArrayList var29 = var8.z().c();
         ArrayList[] var30 = var8.z().e();
         zbtk var31 = var27.J();

         float var22;
         int var32;
         for(var32 = 0; var32 < var23; ++var32) {
            if (var1.g()) {
               var19 = (float)var2 + var26 * (float)var32;
               var20 = (float)var16.h();
               var22 = var20 + (float)var1.m();
               var1.d().a(var19, var20, var19, var22);
            }

            int var33 = var32;
            if (var11) {
               var33 = var23 - var32 - 1;
            }

            String var34 = "";
            if (var33 < var28.getCount() && var8.z().e() == null) {
               zafr var52 = var28.a(var33);
               var34 = zpw.a(var8.al(), var52.a(), var52.c(), var52.b());
            } else if (var33 < var29.size()) {
               zfp var35 = (zfp)var29.get(var33);
               var34 = zpw.a(var8.al(), var35.a(), var35.c(), var35.b());
            }

            com.aspose.cells.b.a.b.zq var54 = new com.aspose.cells.b.a.b.zq((float)var2 + (float)var32 * var26, (float)(var3 + var7), var26, (float)(var1.m() - var7));
            com.aspose.cells.b.a.b.zv var36 = new com.aspose.cells.b.a.b.zv(com.aspose.cells.b.a.b.zv.c());
            var36.c(0);
            var36.a(1);
            var0.a(var34, var24, var25, (com.aspose.cells.b.a.b.zq)var54, var36);
         }

         String var37;
         if (var30 != null && var30.length > 0 && var8.z().c().size() > 0) {
            zbp var48 = var8.e();
            float var49 = (float)var7;
            float var51 = (float)(var30.length + 1) * var49;
            ArrayList var55 = var30[0];
            zfp var56 = (zfp)var55.get(0);
            var37 = zpw.a(var8.al(), var56.a(), var56.c(), var56.b());
            zbsq.a(var48.e().ap(), var37, 0, var24, (com.aspose.cells.b.a.b.zs)(new com.aspose.cells.b.a.b.zs(var4, var1.l())), 1, 1);
            float var39 = (float)var3;
            boolean var40 = false;
            float var41 = (float)var17.h();
            float var42 = 0.0F;
            if (!var11) {
               var42 = (float)var16.g();
            } else {
               var42 = (float)var16.i();
            }

            a(var0, var30, var42, var41, var49, var40, var48, (double)var26, var1, 1, var39, var16, false);
         }

         for(var32 = 0; var32 < var15.size(); ++var32) {
            zalb var50 = (zalb)var15.get(var32);
            zbcq var53 = var50.k();
            float var57 = (float)var17.h() + (float)var32 * var18;
            float var58 = 0.0F;
            if (var1.f()) {
               com.aspose.cells.b.a.b.zq var59 = new com.aspose.cells.b.a.b.zq((float)(var17.g() + zald.a), var57, var14.b(), var18);
               zald.a(var0, var8.x(), var59, var50);
               var58 = var14.b() + (float)zald.a;
            }

            var37 = var53.i();
            com.aspose.cells.b.a.b.zt var38 = zbsq.b(var0, var37, var24);
            com.aspose.cells.b.a.b.zo var60 = new com.aspose.cells.b.a.b.zo((float)(var2 - var12.b()) + var58, var57 + var18 / 2.0F - var38.c() / 2.0F);
            var0.a(var37, var24, (com.aspose.cells.b.a.b.zc)var25, (com.aspose.cells.b.a.b.zo)var60);

            for(int var61 = 0; var61 < var23; ++var61) {
               if (var1.g() && var61 < var23 - 1) {
                  var19 = (float)var2 + (float)(var61 + 1) * var26;
                  var22 = var57 + var18;
                  var1.d().a(var19, var57, var19, var22);
               }

               if (var61 <= var53.E().getCount() - 1) {
                  int var62 = var61;
                  if (var11) {
                     var62 = var53.E().getCount() - var61 - 1;
                  }

                  zje var63 = var53.E().b(var62);
                  if (!var63.a() && (var63.x() == null || !com.aspose.cells.b.a.zr.a(var63.x()).equals("#N/A"))) {
                     String var43 = var63.z();
                     boolean var44 = var63.A();
                     var37 = zpw.a(var8.al(), var63.v(), var43, var44);
                     var38 = zbsq.b(var0, var37, var24);

                     float var45;
                     for(var45 = (float)var2 + (float)var61 * var26; var26 - (float)var7 < var38.b() && var37.length() > 0; var38 = zbsq.b(var0, var37, var24)) {
                        var37 = var37.substring(0, 0 + (var37.length() - 1));
                        if (var37.charAt(var37.length() - 1) == '.') {
                           var37 = var37.substring(0, 0 + (var37.length() - 1));
                        }
                     }

                     var45 += var26 / 2.0F - var38.b() / 2.0F;
                     float var46 = var26 - (var26 / 2.0F - var38.b() / 2.0F);
                     var60 = new com.aspose.cells.b.a.b.zo(var45, var57 + var18 / 2.0F - var38.c() / 2.0F);
                     com.aspose.cells.b.a.b.zv var47 = new com.aspose.cells.b.a.b.zv(com.aspose.cells.b.a.b.zv.c());
                     var0.a(var37, var24, var25, (com.aspose.cells.b.a.b.zo)var60, var47);
                  }
               }
            }
         }

         if (var25 != null) {
            var25.h();
         }

         if (var8.i().c().i() && var8.ap().j() != var9) {
            var8.ap().b(var9);
         }

      }
   }

   private static void a(zn var0, ArrayList[] var1, float var2, float var3, float var4, boolean var5, zbp var6, double var7, ziq var9, int var10, float var11, com.aspose.cells.b.a.b.zp var12, boolean var13) {
      zig var14 = var9.a();
      byte var15 = 0;
      float var16 = var3;
      com.aspose.cells.b.a.b.zt var17 = new com.aspose.cells.b.a.b.zt((float)var7, (float)var12.f() / 2.0F);

      for(int var18 = 0; var18 < var1.length; ++var18) {
         ArrayList var19 = var1[var18];
         com.aspose.cells.b.a.b.zs var20 = a(var0, var19, var15, var9, var17);
         float var21 = var2;

         for(int var22 = 0; var22 < var19.size(); ++var22) {
            zfp var23 = (zfp)var19.get(var22);
            String var24 = zpw.a(var14.al(), var23.a(), var23.c(), var23.b());
            int var25 = zbr.a((zafr)var23);
            float var26 = (float)((double)var25 * var7);
            float var27;
            if (!var6.p()) {
               var27 = var21 + var26 / 2.0F - (float)(var20.b() / 2);
            } else {
               var27 = var21 - var26 / 2.0F - (float)(var20.b() / 2);
            }

            float var28 = var5 ? var16 : var16 - (float)var20.c();
            com.aspose.cells.b.a.b.zq var29 = new com.aspose.cells.b.a.b.zq(var27, var28, (float)var20.b(), (float)var20.c());
            zbr.b(var0, com.aspose.cells.b.a.b.zp.a(var29), var24, var15, var9.b(), var9.c(), 1, var10);
            if (var6.e().l().g()) {
               var9.d().a(var21, var11, var21, var16);
            }

            if (var6.e().l().g()) {
               float var30 = var5 ? var16 + var4 + (float)var20.c() : var16 - (var4 + (float)var20.c());
               a(var0, var23.d(), var21, var11, var30, var5, var6, var7);
            }

            if (!var6.p()) {
               var21 += var26;
            } else {
               var21 -= var26;
            }
         }

         if (var6.e().l().g()) {
            var9.d().a(var21, var11, var21, var16);
         }

         if (var5) {
            var16 += var4 + (float)var20.c();
         } else {
            var16 -= var4 + (float)var20.c();
         }
      }

   }

   static com.aspose.cells.b.a.b.zs a(zn var0, List var1, int var2, ziq var3, com.aspose.cells.b.a.b.zt var4) {
      zig var5 = var3.a();
      int var6 = 0;
      int var7 = 0;

      for(int var8 = 0; var8 < var1.size(); ++var8) {
         zfp var9 = (zfp)var1.get(var8);
         String var10 = zpw.a(var5.al(), var9.a(), var9.c(), var9.b());
         com.aspose.cells.b.a.b.zs var11 = zbsq.a(var0, var10, var2, var3.b(), (com.aspose.cells.b.a.b.zt)var4, 1, 1);
         if (var11.b() > var6) {
            var6 = var11.b();
         }

         if (var11.c() > var7) {
            var7 = var11.c();
         }
      }

      return new com.aspose.cells.b.a.b.zs(var6, var7);
   }

   private static void a(zn var0, zafs var1, float var2, float var3, float var4, boolean var5, zbp var6, double var7) {
      float var9 = var2;

      for(int var10 = 0; var10 < var1.getCount(); ++var10) {
         zfp var11 = (zfp)var1.a(var10);
         int var12 = zbr.a((zafr)var11);
         float var13 = (float)((double)var12 * var7);
         if (!var6.p()) {
            var9 += var13;
         } else {
            var9 -= var13;
         }

         var6.e().k().d().a(var9, var3, var9, var4);
      }

   }

   static com.aspose.cells.b.a.b.zs a(zn var0, ziq var1) throws Exception {
      com.aspose.cells.b.a.b.zt var2 = b(var0, var1);
      int var3;
      com.aspose.cells.b.a.b.zt var5;
      if (var1.f()) {
         var5 = zald.a(var0, var1.a().x());
         var3 = (int)(var5.b() + var2.b()) + zald.a + 1;
      } else {
         var3 = (int)var2.b() + 1;
         if (var2.b() == 0.0F) {
            var3 += zald.a;
         }
      }

      int var4;
      if (var2.c() == 0.0F) {
         var5 = var0.a("A", var1.b());
         var4 = (int)((double)var5.c() + 0.5D) + 1 + zald.a;
      } else {
         var4 = (int)((double)var2.c() + 0.5D) + 2;
      }

      if (var3 > var1.a().a()) {
         var3 = var1.a().a();
      }

      if (var3 > var1.a().i().l() - 2 * zia.a) {
         var3 = var1.a().i().l() - 2 * zia.a;
      }

      return new com.aspose.cells.b.a.b.zs(var3, var4 * var1.a().A().getCount());
   }

   private static com.aspose.cells.b.a.b.zt b(zn var0, ziq var1) {
      zbcs var3 = var1.a().z();
      com.aspose.cells.b.a.b.zt var4 = new com.aspose.cells.b.a.b.zt(0.0F, 0.0F);

      for(int var6 = 0; var6 < var3.getCount(); ++var6) {
         zbcq var2 = var3.c(var6);
         com.aspose.cells.b.a.b.zt var5 = var0.a(var2.i(), var1.b());
         if (var4.b() < var5.b()) {
            var4.a(var5.b());
         }

         if (var4.c() < var5.c()) {
            var4.b(var5.c());
         }
      }

      return var4;
   }

   static int a(zn var0, ziq var1, com.aspose.cells.b.a.b.zp var2) {
      zig var3 = var1.a();
      com.aspose.cells.b.a.b.zs var4 = zbsq.a(var0, "a", var1.b());
      int var5 = var4.b() * var1.a().e().G().c() / 300;
      byte var6 = 0;
      int var18 = var6 + var5;
      com.aspose.cells.b.a.b.zg var7 = var1.b();
      zig var8 = var1.a();
      ArrayList var9 = var8.z().c();
      ArrayList[] var10 = var8.z().e();
      float var11 = (float)var2.e() / (float)var9.size();
      com.aspose.cells.b.a.b.zt var12 = new com.aspose.cells.b.a.b.zt(var11, (float)var2.f() / 2.0F);
      com.aspose.cells.b.a.b.zs var13 = new com.aspose.cells.b.a.b.zs(0, 0);
      int var14;
      com.aspose.cells.b.a.b.zs var17;
      if (var9.size() > 0) {
         for(var14 = 0; var14 < var9.size(); ++var14) {
            zfp var15 = (zfp)var9.get(var14);
            String var16 = zpw.a(var3.al(), var15.a(), var15.c(), var15.b());
            var17 = zbsq.a(var0, var16, 0, var7, (com.aspose.cells.b.a.b.zt)var12, 1, 1);
            if (var17.b() > var13.b()) {
               var13.a(var17.b());
            }

            if (var17.c() > var13.c()) {
               var13.b(var17.c());
            }
         }
      } else {
         var13 = zbsq.a(var0, "123", 0, var7, (com.aspose.cells.b.a.b.zt)var12, 1, 1);
      }

      var18 += var13.c();
      var1.b(var18);
      var14 = 0;
      if (var10 != null && var10.length > 0 && var9.size() > 0) {
         var18 += var5 * var10.length;

         for(int var19 = 0; var19 < var10.length; ++var19) {
            ArrayList var20 = var10[var19];
            var17 = a(var0, var20, 0, var1, var12);
            var14 += var17.c();
         }
      }

      var18 += var14;
      return var18;
   }
}
